clc;
close all;
clear;
%% This script calculate the power loss of soft-charging SC converters by 
% considering a second order system of a simple RLC circuit


%%
L=0.1e-6;
C=10e-6;
R=1000e-3;
f=1000e3;    %switching frequency
period=1/2/f;   % duration of a phase

% test step resposne
num=[1/L 0];
den=[1 R/L 1/L/C];
ic=tf(num,den);
step(ic,period);
  

break


i=0;
xrange=4:0.1:7;
for x=xrange
    i=i+1;
    f=10^x;
    period=1/2/f;
    num=[1/L 0];
    den=[1 R/L 1/L/C];
    vc=tf(num,den);
    [ic,t]=step(vc,period);
    ploss(i)=sum(ic.^2*R)/period;
end
loglog(10.^xrange,ploss./(10.^xrange))
% ploss=